package com.atguigu.oshi.demos.common;

import lombok.Data;

/**
 * @program: oshi
 * @description: 返回给前端的数据格式
 * @author: Mr.Yan
 * @create: 2024-12-08 16:42
 **/
@Data
public class R {
private int code;
private String msg;
private Object data;


public R(int code, String msg) {
this.code = code;
this.msg = msg;
}
public R(int code, String msg, Object data) {
 this.code = code;
 this.msg = msg;
 this.data = data;
}
//快速创建成功和失败的R对象
public static R ok() {
return new R(200, "success");
}
public static R ok(Object data) {
return new R(200, "success", data);
}
public static R error() {
return new R(500, "error");
}
public static R error(Object data) {
return new R(500, "error", data);
}
public  static R error(int code, String msg) {
 return new R(code, msg);
}
}
